package com.hkx.smipleemps.common.utils;

import java.util.List;

/**
 * 分页器
 * @param <T>
 */
public class PageInfo<T> {
    private int pageNo;
    private int pageSize;
    private List<T> list;
    private int count ;
    private int totalPage;
    private int nextPage;
    private int prePage;
    private boolean first;
    private boolean last;


    public boolean isFirst() {
        return pageNo==1;
    }

    public boolean isLast() {
        return pageNo==totalPage;
    }

    public PageInfo(int pageNo, int pageSize, int count, List<T> list) {
        this.pageNo = pageNo;
        this.pageSize=pageSize;
        this.count = count;
        this.list = list;
        this.totalPage  =  count/pageSize +(count%pageSize==0?0:1);
    }

    public int getPageNo() {
        return pageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public List<T> getList() {
        return list;
    }

    public int getCount() {
        return count;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public int getNextPage() {
        this.nextPage = pageNo+1;
        if(nextPage>=totalPage){
            nextPage =totalPage;
        }
        return nextPage;
    }

    public int getPrePage() {
        this.prePage = this.pageNo-1;
        if(prePage<1){
            prePage=1;
        }
        return prePage;
    }
}
